home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / mod2tutr.zip / CHAP16.TXT < prev    next >
Text File  |  1989-01-18  |  7KB  |  176 lines

  1.  
  2.                                                     Chapter 16
  3.  
  4.                                      COMPLETE EXAMPLE PROGRAMS
  5.  
  6.  
  7.  
  8. WHY THIS CHAPTER?
  9. ______________________________________________________________
  10.  
  11. The intent of this chapter is to give several example programs
  12. that use nearly every capability of Modula-2 as illustrations
  13. of large usable programs.  The programs are usable utilities,
  14. but primarily they are intended to illustrate the method of
  15. building up a medium sized program from the various constructs
  16. studied in the earlier chapters.  Even though most of these
  17. programs are designed to be run on an IBM-PC or compatible,
  18. the techniques are applicable to any system by changing the
  19. system calls.
  20.  
  21. The first three programs are the beginning of a hard disk
  22. backup utility.  Although it works, it does have a few
  23. limitations that need fixed before it can really be used for
  24. a production backup system.  It has never been refined, but
  25. it is included here as an illustration of how to put together
  26. a large program in Modula-2.  It can be used as a backup
  27. system if you don't mind the following problems and
  28. limitations.
  29.  
  30. 1.   The date and time of the files on the copy are the date
  31.      and time that the copies are made, not the original date
  32.      on the original files.
  33.  
  34. 2.   This system does not copy hidden files.
  35.  
  36. 3.   This system does not copy files that are too big to fit
  37.      on one floppy disk.
  38.  
  39. 4.   The filesize and the room remaining on the disk are
  40.      handled using floating point numbers because LONGCARD was
  41.      not available when this program was originally written.
  42.      There are enough significant digits in the floating point
  43.      numbers to allow this, but using the long cardinal type
  44.      would be a great improvement.
  45.  
  46. The interested student may wish to use this as a beginning
  47. point to develop his own hard disk backup system, and learn
  48. a lot about the use of Modula-2 at the same time.
  49.  
  50.  
  51. BAKLIST.MOD
  52. ______________________________________________________________
  53.  
  54. This program generates a list of all files along with their
  55. sub-directories.  Some files are excluded from the list,
  56. including all three files that comprise the DOS system and the
  57. file generated here, FULLDISK.LST.  This is an ASCII file that
  58.  
  59.                                                           16-1
  60.  
  61.                         Chapter 16 - Complete Example Programs
  62.  
  63. can be edited with any text editor to eliminate any files that
  64. you do not wish to back up.  It should be noted that the file,
  65. FULLDISK.LST, is created and filled in the root directory of
  66. the default drive.
  67.  
  68. Select the desired sub-directory that you wish to back up, by
  69. making it the default directory, and all files and sub-
  70. directories, along with all of their respective contents will
  71. be listed in FULLDISK.LST.  The resulting list is then used
  72. by BAKCOPY.MOD to actually copy the files to floppy disks.
  73.  
  74. This program uses a B-tree sorting algorithm using dynamic
  75. allocation and recursive techniques.  The B-tree record is
  76. imported from the module named DirHelps.
  77.  
  78.  
  79. BAKCOPY.MOD
  80. ______________________________________________________________
  81.  
  82. This program uses FULLDISK.LST to actually copy the files from
  83. the source disk to the target and requests a disk change
  84. whenever the floppy disk fills up.  It will not copy a file
  85. larger than that which will fit on one disk, but will give a
  86. message of which files are not copied.
  87.  
  88. This program makes no provision for copying a file with an
  89. unusual file attribute and simply copies the entire file if
  90. disk space is available.  It also does no file lookahead.
  91. When the next file doesn't fit on the target disk, it simply
  92. requests a new disk.  A lookahead scheme could allow several
  93. additional smaller files to be copied to a disk when a larger
  94. file will not fit.
  95.  
  96.  
  97.  
  98. BAKRSTR.MOD
  99. ______________________________________________________________
  100.  
  101. This program will read the files from floppy back to the fixed
  102. disk to restore it.  It simply copies from whatever directory
  103. they are in to the corresponding directory on the fixed disk,
  104. creating the directory if necessary.  This program uses some
  105. of the procedures from the module named DirHelps.  This was
  106. done to illustrate reusability of software.
  107.  
  108. All three of these programs are usable but lack many of the
  109. refinements necessary to make them completely useful.  As the
  110. purchaser of this tutorial, you are permitted to use these
  111. source files as the basis for developing your own hard disk
  112. backup program.  If you develop them carefully, you will learn
  113. a lot about the use of Modula-2.
  114.  
  115.  
  116.  
  117.                                                           16-2
  118.  
  119.                         Chapter 16 - Complete Example Programs
  120.  
  121. GENERAL PURPOSE GLOBAL MODULES
  122. ______________________________________________________________
  123.  
  124. The remainder of the files in this chapter are useful global
  125. modules which you may be able to use in some of your Modula-
  126. 2 programs.  They are fairly well documented as to their
  127. capabilities and limitations, and since you have the source
  128. code, you are able to customize them to fit your particular
  129. need.
  130.  
  131.  
  132. DIRHELPS.DEF   DIRHELPS.MOD
  133. ______________________________________________________________
  134.  
  135. This global module contains several useful file handling and
  136. directory manipulation procedures.  It is called by the above
  137. three example programs used for backup and restore of a fixed
  138. disk.  These routines are available for your use also if you
  139. desire to use them for a file manipulation program.  Their
  140. main intent however is that they be a guide for the student
  141. to observe methods used to write library functions.
  142.  
  143.  
  144. BITOPS.DEF     BITOPS.MOD
  145. ______________________________________________________________
  146.  
  147. This module has four generic bit operations including logical
  148. AND, OR, XOR, and NOT.  These are useful procedures that you
  149. can import and use in your programs if you are doing bit
  150. manipulations.
  151.  
  152.  
  153. REAL2MON.DEF   REAL2MON.MOD
  154. ______________________________________________________________
  155.  
  156. This module has a procedure to output real data to the monitor
  157. in a neat, easy to read format.  It is documented in the
  158. header of the source files.
  159.  
  160.  
  161. REAL2FIL.DEF   REAL2FIL.MOD
  162. ______________________________________________________________
  163.  
  164. This module has several procedures to output real and other
  165. data type to a file using the FileSystem module.  The various
  166. procedures are documented in their respective headers.
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.                                                           16-3
  175.  
  176.